home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Programming / EasyPLUGINs / examples / dclistview_demo.e next >
Text File  |  1998-01-11  |  2KB  |  76 lines

  1. OPT PREPROCESS, OSVERSION=37
  2.  
  3. MODULE 'tools/exceptions', 'tools/EasyGUI', 'exec/nodes', 'exec/lists',
  4.        'easyplugins/dclistview', 'tools/constructors', 'utility', 'utility/tagitem'
  5.  
  6. DEF result=-1
  7.  
  8. PROC main() HANDLE
  9.   DEF dclist:PTR TO dclistview_plugin
  10.   DEF list, a, nodes
  11.  
  12.   IF (utilitybase:=OpenLibrary('utility.library', 37))=NIL THEN Raise("utlb")
  13.  
  14.   list:=newlist()
  15.  
  16.   nodes:=['zero','one','two','three','four','five','six','seven',
  17.           'eight','nine','ten','eleven','twelve','thirteen','fourteen']
  18.  
  19.   ForAll({a}, nodes, `AddTail(list, newnode(NIL, a)))
  20.  
  21.   NEW dclist.dclistview([PLA_DCListView_Label,       'L_abel',
  22.                          PLA_DCListView_RelativeX,   15,
  23.                          PLA_DCListView_RelativeY,   7,
  24.                          PLA_DCListView_ExecList,    list,
  25.                          PLA_DCListView_Current,     result,
  26.                          PLA_DCListView_DoubleClick, {dc_listaction},
  27.                          PLA_DCListView_Key,         "a",
  28.                          TAG_DONE])
  29.  
  30.   easyguiA('Double Click test',
  31.           [EQROWS,
  32.             [DCLIST, {sc_listaction}, dclist, TRUE],  ->note use OF ID constant (=PLUGIN)
  33.             [EQCOLS,
  34.               [SBUTTON, {okaction}, '_OK', dclist, "o"],
  35.               [SBUTTON, {disabler}, '_Disable', dclist, "d"],
  36.               [SBUTTON, {cancelaction}, '_Cancel', NIL, "c"]
  37.             ]
  38.           ])
  39. EXCEPT DO
  40.  
  41.     END dclist
  42.  
  43.     IF exception<>"QUIT" THEN report_exception()
  44.  
  45.     IF utilitybase THEN CloseLibrary(utilitybase)
  46.  
  47. ENDPROC
  48.  
  49. PROC sc_listaction(info, dclist:PTR TO dclistview_plugin)
  50.  
  51.   PrintF('Current Selection: \d\n', dclist.get(PLA_DCListView_Current))
  52.  
  53. ENDPROC
  54.  
  55. PROC dc_listaction(dclist:PTR TO dclistview_plugin, current) IS okaction(dclist, NIL)
  56.  
  57. PROC okaction(dclist:PTR TO dclistview_plugin, info)
  58.  
  59.   IF (result:=dclist.get(PLA_DCListView_Current))= -1
  60.     PrintF('No selection made\n')
  61.     cancelaction(info)
  62.   ENDIF
  63.   PrintF('Final Selection: \d\n',result)
  64.   quitgui(result)
  65.  
  66. ENDPROC
  67.  
  68. PROC disabler(dclist:PTR TO dclistview_plugin, info)
  69. ENDPROC dclist.set(PLA_DCListView_Disabled, dclist.get(PLA_DCListView_Disabled)=FALSE)
  70.  
  71. PROC cancelaction(info)
  72.   PrintF('Operation cancelled.\n')
  73.   quitgui()
  74. ENDPROC
  75.  
  76.